/* eslint-disable no-use-before-define */

import axios, { type Paging, type Response } from '@/utils/axios/axios';

/** 查询签到记录  - 分页 */
export function getSignRecordsAxios(current: number, size: number): Promise<Response<Paging<SignRecords>>> {
  return axios.get(`/app/signRecord/getAppSignPage`, { data: { current, size } }) as Promise<Response<Paging<SignRecords>>>;
}

/** 签到 */
export function addSignAxios(): Promise<Response<SignRecords>> {
  return axios.post(`/app/signRecord/addSingRecord`) as Promise<Response<SignRecords>>;
}

/** 得到最近一周的签到记录 */
export function getSignInWeekListAxios(): Promise<Response<SignInWeek>> {
  return axios.get(`/app/signRecord/getWeekSignRecord`) as Promise<Response<SignInWeek>>;
}

/** 得到用户信息 */
export function getUserInfoAxios(token: string): Promise<Response<UserInfo>> {
  return axios.get(`/app/user/getUserInfo`, { header: { 'Dsbb-Custom-Access-Token': token } }) as Promise<Response<UserInfo>>;
}

/** 更新用户资料 */
export function updateUserInfoAxios(data: { avatar: string } | { sex: number; birthday: string; nickname: string }): Promise<Response<string>> {
  return axios.post(`/app/user/updateUser`, data) as Promise<Response<string>>;
}

/** 得到基础词典信息 */
export function queryBaseDictInfoAxios(): Promise<Response<BaseDictInfo>> {
  return axios.get(`/app/dict/getDictParam`) as Promise<Response<BaseDictInfo>>;
}

export type BaseDictInfo = {
  /** 抖音客服在账号 */
  DY_SUPPORT_STAFF: string;
  /** 人民币兑换K币兑换比例 */
  PRICE_VIRTUAL_RATE: string;
  /** 客服电话 */
  APP_CUSTOMER_TEL: string;
  /**抖音客服ID*/
  CONTACT_CUSTOMER_ID: string;
};

export type SignRecords = {
  /** 连续签到天数 */
  continueDayNum: number;
  /** 创建时间 */
  createTime: string;
  /** 最后签到时间 */
  lastSignTime: string;
  /** 签到标题  */
  signTitle: string;
  /** 签到奖励K币数 */
  virtualCoins: number;
};

export type SignInWeek = {
  /** 是否签到：0-未签到；1-已签到； */
  isSign: number;
  /** 周几  */
  weekDayName: string;
  /** 奖励的K币 */
  virtualCoins?: number;
};

export type UserInfo = {
  /** 头像 */
  avatar: string | null;
  /** 昵称 */
  nickname: string;
  /** 用户ID */
  userId: number;
  /** vip到期时间 */
  vipExpireTime: string;
  /** K币数 */
  virtualCoins: number;
  /** 是否为 VIP */
  isVip: number;
  /** VIP 等级 */
  vipLevel: string;
  /** 性别 */
  sex: 0 | 1 | 2;
  /** 生日 */
  birthday: string;
  /** 加密的手机号 */
  phone: string;
  /** 是否为合作方 0-否；1-是 */
  isPartner: 0 | 1;
  /** 是否自动解锁 */
  isAutoPay: 0 | 1;
};
